using System;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows.Markup;

namespace QueryBuilder.Controls.Configuration
{
    /// <summary>
    /// 
    /// </summary>
    [ContentProperty("VisualizationMapping")]
    public class VisualizationConfig
    {
        private Collection<VisualizationMapping> visualizationMapping = new Collection<VisualizationMapping>();

        /// <summary>
        /// Gets or sets the comparison style key.
        /// </summary>
        /// <value>The comparison style key.</value>
        public string ComparisonViewerStyleKey { get; set; }

        /// <summary>
        /// Gets or sets the comparison exitor style key.
        /// </summary>
        /// <value>The comparison exitor style key.</value>
        public string ComparisonEditorStyleKey { get; set; }

        /// <summary>
        /// Gets or sets the visualization mapping.
        /// </summary>
        /// <value>The visualization mapping.</value>
        public Collection<VisualizationMapping> VisualizationMapping
        {
            get { return this.visualizationMapping; }
        }

        /// <summary>
        /// Gets the mapping.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        public VisualizationMapping GetMapping(Type type)
        {
            return this.visualizationMapping.FirstOrDefault(m => string.Equals(m.TypeName.AssemblyQualifiedName, type.AssemblyQualifiedName));
        }
    }
}